package testy;

import java.awt.CardLayout;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class AnalystHomePanel extends JPanel {
	
	final JButton btnOpen;
	
	JButton btnNew;
	
	JButton btnLogout;
	
	RFPgui parent;
	
	public AnalystHomePanel(RFPgui gui) {
		super();
		parent = gui;
		btnOpen = new JButton("Open");
		btnOpen.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JFileChooser jf = new JFileChooser();
				jf.showOpenDialog(btnOpen);
				File file = jf.getSelectedFile();
				Desktop desktop = Desktop.getDesktop();
				
				try {
					if (file !=  null)
						desktop.open(file);
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnOpen.setBounds(164, 178, 103, 29);
		add(btnOpen);
		
		btnNew = new JButton("New");
		btnNew.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				File file = new File("blank.docx");
				Desktop desktop = Desktop.getDesktop();
				
				try {
					desktop.open(file);
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNew.setBounds(6, 178, 117, 29);
		add(btnNew);
		
		JLabel lblWelcome = new JLabel("Welcome");
		lblWelcome.setBounds(187, 34, 137, 16);
		add(lblWelcome);
		
		btnLogout = new JButton("Logout");
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout c = ((CardLayout) (parent.frame.getContentPane()).getLayout());
				c.show(parent.frame.getContentPane(), "name_1417317733020304000");
				parent.pinField.setText("");
				parent.passwordField.setText("");
			}
		});
		btnLogout.setBounds(306, 178, 117, 29);
		add(btnLogout);
		/*
		final JButton btnOpen = new JButton("Open");
		btnOpen.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JFileChooser jf = new JFileChooser();
				jf.showOpenDialog(btnOpen);
				File file = jf.getSelectedFile();
				Desktop desktop = Desktop.getDesktop();
				
				try {
					if (file !=  null)
						desktop.open(file);
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnOpen.setBounds(164, 178, 103, 29);
		homePanel.add(btnOpen);
		
		
		
		JButton btnNew = new JButton("New");
		btnNew.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				File file = new File("blank.docx");
				Desktop desktop = Desktop.getDesktop();
				
				try {
					desktop.open(file);
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnNew.setBounds(6, 178, 117, 29);
		homePanel.add(btnNew);
		
		JLabel lblWelcome = new JLabel("Welcome");
		lblWelcome.setBounds(187, 34, 137, 16);
		homePanel.add(lblWelcome);
		
		JButton btnLogout = new JButton("Logout");
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CardLayout c = ((CardLayout) (frame.getContentPane()).getLayout());
				c.show(frame.getContentPane(), "name_1417317733020304000");
				pinField.setText("");
				passwordField.setText("");
			}
		});
		btnLogout.setBounds(306, 178, 117, 29);
		homePanel.add(btnLogout);*/
	}
}
